<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
</head>
<body>
<script>
	let arr = [1,2,3];
	let arrSum = arr.reduce(function (tmp,item,index) {
	  return tmp+item;
	});
	//console.log(arrSum);
	let arrAverage = arr.reduce( (tmp,item,index) => {
		if (arr.length - 1 != index) {//不是最后一次
			return tmp + item;
		}else {
			return (tmp + item)/arr.length;
		}
	});
	console.log(arrAverage);
</script>
</body>
</html>